from struct import unpack

class ReadBinary(object):
    def loadBinary(self, file_):
        self.instruction = []
        self.b4 = True

        while(self.b4):
            self.b4 = file_.read(4)
            if (self.b4):
                self.instruction.append( unpack('<I', self.b4)[0] )

        self.textLen = self.instruction[0]
        self.ktextLen = self.instruction[1]
        self.textStart = 0x2
        self.ktextStart = self.textStart + self.textLen
        self.dataStart = self.ktextStart + self.ktextLen

    def returnBinary(self):
        return self.instruction

    def returnText(self):
        return self.instruction[self.textStart:self.ktextStart]

    def returnKtext(self):
        return self.instruction[self.ktextStart:self.dataStart]

    def returnData(self):
        return self.instruction[self.dataStart:]